﻿using SYH.Domain.Applicaton;
using SYH.IBLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SYH.Web.Controllers.Apis
{
    /// <summary>
    /// 示范例子，不是业务
    /// </summary>
    public class IExampleController : BaseController
    {
        private readonly IEntityRepository<SystemUser> _UserService;
        public IExampleController(IEntityRepository<SystemUser> UserService)
        {
            _UserService = UserService;
        }

        // GET: IExample
        /// <summary>
        /// 获取列表数据
        /// </summary>
        /// <returns></returns>
        public ActionResult Index(int index, int size, string name)
        {
            var count = 0;
            var list = _UserService.GetBoPaginate(index, size, o => o.SortCode,w=>w.Name.Contains(name), out count);
            return Table(list, count);
        }

        /// <summary>
        /// 获取详细信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Get(Guid id)
        {
            //读取操作
            var bean = _UserService.GetBo(id);
            return JsonData(bean);
        }

        /// <summary>
        /// 保存数据
        /// </summary>
        /// <returns></returns>
        public ActionResult Save(SystemUser bean)
        {
            //业务代码
            return Error("此处不做具体业务操作！");
        }
    }
}